package org.wlc.service;


import org.wlc.dao.UserDao;

import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

/**
 * @author 王立朝
 * @description 用户服务类
 * @date 2021-11-15 14:19:59
 */
public class UserService {


    /**
     * SpringIOC 容器注入方式：
     * set方式注入
     * 1) 在需要注入的类中加入setter方法
     * 2） 在配置文件中加入property 属性，ref依赖 被注入的对象
     */
    /**
     * java bean注入
     */
    private UserDao userDao;

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    /**
     * 基本类型注入
     */
    private String ip;

    public void setIp(String ip) {
        this.ip = ip;
    }

    /**
     * 注入list 类型
     */
    private List<String> list;

    public void setList(List<String> list) {
        this.list = list;
    }

    private Set<String> set;

    public void setSet(Set<String> set) {
        this.set = set;
    }

    private Map<String, Object> maps;

    public void setMaps(Map<String, Object> maps) {
        this.maps = maps;
    }

    private Properties properties;

    public void setProperties(Properties properties) {
        this.properties = properties;
    }

    public void printList() {
        list.stream().forEach(e -> {
            e = e.toUpperCase();
            System.out.println(e);
            System.out.println();
        });
    }

    /**
     * set
     */
    public void printSet() {
        set.stream().forEach(e -> {
            e = e.toUpperCase();
            System.out.println(e);
        });
    }

    public void printMap() {
        maps.forEach((k, v) -> System.out.println(k + "=" + v));
    }

    public void printProperties() {
        properties.forEach((k, v) -> System.out.println(k + "=" + v));
    }

    public void test() {
        userDao.method01(ip);
        printList();
        printSet();
        printMap();
        printProperties();
    }
}
